package com.szp.lagou.mq.rocketmq.dao;

import com.szp.lagou.mq.rocketmq.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderDao {
    @Select("select id, productId, price, status, createTime, updateTime  from orders where id = #{id}")
    Order getOrderById(String id);

    @Select("select id, productId, price, status, createTime, updateTime  from orders")
    List<Order> getOrders();

    @Insert({"insert into orders (id, productId, price, status)" +
            " values(#{id}, #{productId}, #{price}, #{status})"})
    Integer addOrder(Order order);

    @Update({"update orders set status=#{status} where id = #{id}"})
    Integer updateOrderStatusById(String id, String status);

    @Select("select id, productId, price, status, createTime, updateTime  from orders where status = '0' limit #{count}")
    List<Order> getUnPayOrders(int count);
}
